<?php $this->load->view('header'); ?>
<style>
.sortUp {	color:red; }
.sortDown {	color:blue; }
</style>
<div id="content">
<div class="column full fl">
		
		<div class="box">
		<div class="box-header"><?php echo get_title();?></div>
		<div class="box-content box-table">
		<br />
		
		&nbsp;&nbsp;
		<?php echo isAccess('myuser','user','add') ? anchor('myuser/user/add', '<span class="icon_text addnew"></span>Tambah User', 'class="button white"') : ''; ?>
		<div class="clear"></div>
		<br />
		
		<?php if (isset($errorMessage)) : ?>
            <div class="notification <?php echo ((isset($isSuccess) && $isSuccess) ? 'success' : 'error');?>"><?php echo $errorMessage; ?></div>
        <?php endif; ?>    	

		<div class="clear"></div>
		<br /><br />
		&nbsp;&nbsp;&nbsp;<b>Berdasarkan Data User :</b>
		<br /><br />
		
		&nbsp;&nbsp; Group : 
		<select name='group' id='groupId' class="modalLoader">
			<option value='0'>All</option>
			<?php if($listGroup) foreach($listGroup as $row):?>
				<option value='<?php echo $row['groupId']?>' <?php echo $row['groupId'] == get_data($uri_to_assoc,'groupId') ? 'selected="selected"' : ''?>' >
					<?php echo sprintf("%+'-".($row['level'] * 4)."s",  ' ').$row['groupName']?>
				</option>
			<?php endforeach;?>
		</select>
		&nbsp;&nbsp; Status : <?php echo form_dropdown('userStatus',$listStatus,$uri_to_assoc['userStatus'],'id="userStatus" class="modalLoader"');?>
        <br /><br /><br />
        
        <!-- Total Row -->
        <?php if($totalRow != 0):?>
	        &nbsp;&nbsp;&nbsp;
	        <b>Total : <?php echo $totalRow?> Data</b>
	        <div class='clear'></div>
	        <br />
        <?php endif;?>
        
       	<!-- Search -->
		<div class="box-header fl">
			<?php echo form_open('myuser/user/view/groupId/'.$uri_to_assoc['groupId'].'/userStatus/'.$uri_to_assoc['userStatus'].'/limit/'.get_data($uri_to_assoc,'limit') , array('name'=>'formSearchBerkala', 'id'=>'formSearchBerkala', 'class'=>'frModalLoad'),array('kirim'=>'kirim')); ?>
				<select name='searchFrom' id='searchFrom'>
					<?php if ($searchTipe) foreach ($searchTipe as $k=>$v) : ?>
					<option value='<?php echo $k?>' <?php if ($k == get_data($uri_to_assoc,'searchFrom')): ?>selected="selected"<?php endif;?> >
						<?php echo $v?>
					</option>
					<?php endforeach;?>
				</select>
				
				<input type="text" name="keyword" id="keyword" value="<?php echo get_data($uri_to_assoc,'keyword') == 'all' ? '' : myUrlDecode(get_data($uri_to_assoc,'keyword'))?>" class="form-field full" style="width:200px;">
				<?php echo form_submit('submit','Cari', 'class="button themed"');?>
			<?php echo form_close();?>
		</div>
		<!-- End Search -->

		<!-- Limit DropDown -->
		<div class="box-header fr">
		&nbsp;&nbsp; Tampilkan : 
		<select name='list_limit' id='list_limit' class='modalLoader'>
			<?php if ($list_limit) foreach ($list_limit as $k=>$v) : ?>
			<option value='<?php echo $k?>' <?php if ($k == $uri_to_assoc['limit']): ?>selected="selected"<?php endif;?> >
				<?php echo $v?>
			</option>
			<?php endforeach;?>
		</select>
		</div>
		<div class="clear"></div>
		<!-- End Limit DropDown -->
       	
        <?php echo $paging?>
		<table class="tablebox">
		<thead class="table-header" style="border-top:1px solid #ccc;border-bottom:1px solid #ccc">
		<tr>
              <?php /* <th>No</th>
              <th><?php echo anchor_sort('myuser/user/view',$uri_to_assoc,'userLogin',$this->lang->line('myuser_user_login'))?></th>
              <th><?php echo anchor_sort('myuser/user/view',$uri_to_assoc,'userName',$this->lang->line('myuser_user_name'))?></th>
              <th><?php echo anchor_sort('myuser/user/view',$uri_to_assoc,'userStatus',$this->lang->line('global_status'))?></th>
              <th width="450"><?php echo $this->lang->line('global_action')?></td>*/ ?>

              <th>No</th>
              <th><?php echo $this->lang->line('myuser_user_login')?></th>
              <th><?php echo $this->lang->line('myuser_user_name')?></th>
              <th><?php echo $this->lang->line('global_status')?></th>
              <th width="350"><?php echo $this->lang->line('global_action')?></td> 
		</tr>
		</thead>
		<tbody>
            <?php $i = true ;?>
            <?php $no = $uri_to_assoc['page'] + 1?>
			<?php if ($dataView) : foreach($dataView as $row) : ?>
					<?php $updateLocation = getUserLocation($row['userId']);?>
                    <?php $i = $i ? false : true ; ?>
                    <tr class="<?php echo $i ? 'even' : 'odd' ; ?>">
                        <td><?php echo $no?></td>
                        <td><?php echo $row['userLogin']?></td>
                        <td><?php echo $row['userName']?></td>
                        <td>
                            <?php echo ($row['userStatus'] == 1 ) ? $this->lang->line('global_active') : (($row['userStatus'] == 2 ) ? $this->lang->line('global_delete') : $this->lang->line('global_pending') ) ; ?>
                            <?php if ($row['isLogin']) : ?>
                            <br />(Login)
                            <?php endif;?>
                        </td>
                        <td align="center">
                            <?php echo isAccess('myuser','user','detail')  ? anchor('myuser/user/detail/id/'. $row['userId'] .'/time/' . time(), $this->lang->line('global_detail'), 'class="button white"') : '';?>
                            <?php echo isAccess('myuser','user','resetpasswd')  ? anchor('myuser/user/resetPasswd/id/'. $row['userId'] .'/time/' . time(), 'Password', 'class="button white"') : '';?>
                            
                            <?php echo isAccess('myuser','user','edit')  ? anchor('myuser/user/edit/id/'. $row['userId'] .'/time/' . time(), '<span class="icon_text edit"></span>Edit', 'class="button white"') : '';?>
                            <?php echo isAccess('myuser','user','delete') ? anchor('myuser/user/view/groupId/'.$uri_to_assoc['groupId'].'/userStatus/'.$uri_to_assoc['userStatus'].'/action/delete/id/' . $row['userId'],'<span class="icon_text cancel"></span>Hapus', array('onClick' => "return confirm('".$this->lang->line('global_confirm_delete')."')" , 'class' => "button white")) : ''?>
                            &nbsp;
                        </td>
                    </tr>
                    <?php $no++?>
                    <?php endforeach; endif;?>
		</tbody>
		</table>

		<div id="paging">
                <?php echo $paging;?>
            </div>
		</div>
		</div>
	
	</div>
<script type="text/javascript">
<!--
jQuery(document).ready(function($){
    var groupId    	  = $('#groupId').val() 	== undefined ? '0' : $('#groupId').val();
    var userStatus    = $('#userStatus').val() 	== undefined ? '0' : $('#userStatus').val();
   
    groupChange = function() {
        if (this.value)
            document.location.href = site_url('myuser/user/view/groupId/' + this.value + '/userStatus/' + $('#userStatus').val() +'/searchFrom/'+ $('#searchFrom').val() +'/keyword/<?php echo $getUrlKeyword?>/limit/'+ this.value +'/page/0');
    };
    $('#groupId').bind('change',groupChange);
    userStatusChange = function() {
        if (this.value)
            document.location.href = site_url('myuser/user/view/groupId/' + $('#groupId').val() + '/userStatus/'+ this.value +'/searchFrom/'+ $('#searchFrom').val() +'/keyword/<?php echo $getUrlKeyword?>/limit/'+ this.value +'/page/0');
    };
    $('#userStatus').bind('change',userStatusChange);
    
    limitChange = function() {
        if (this.value)
        	document.location.href = site_url('myuser/user/view/groupId/' + $('#groupId').val() + '/userStatus/'+ $('#userStatus').val() +'/searchFrom/'+ $('#searchFrom').val() +'/keyword/<?php echo $getUrlKeyword?>/limit/'+ this.value +'/page/0');
    };
    $('#list_limit').bind('change',limitChange);
});
//-->
</script>
<?php $this->load->view('footer'); ?>